/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentesPan.java
 *
 * Created on 21 août 2011, 16:26:28
 */
package app.views;

import app.controllers.Cahier;
import app.core.IncludedPan;
import app.core.UpdatedComp;
import app.events.eventobjects.VenteAddedEvent;
import app.events.eventobjects.VenteUpdatedEvent;
import app.events.eventobjects.VenteDeletedEvent;
import app.events.VenteListener;
import javax.swing.JComponent;

/**
 *
 * @author Ghost
 */
public class VentesPan extends javax.swing.JPanel implements IncludedPan {
    
    Cahier cahier;

    /** Creates new form VentesPan */
    public VentesPan() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        listVentesPan1 = new app.views.ListVentesPan();
        tabs = new javax.swing.JTabbedPane();
        newVentePan = new app.views.NewVentePan();
        listVentesPan2 = new app.views.ListVentesPan();

        tabs.addTab("Nouvelle Vente", newVentePan);
        tabs.addTab("Liste des ventes", listVentesPan2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private app.views.ListVentesPan listVentesPan1;
    private app.views.ListVentesPan listVentesPan2;
    private app.views.NewVentePan newVentePan;
    private javax.swing.JTabbedPane tabs;
    // End of variables declaration//GEN-END:variables

    
    public void setCahier(Cahier cahier) {
        this.cahier = cahier;
        cahier.addVenteListener(listVentesPan2);
        newVentePan.setCahier(cahier);
    }
    
    @Override
    public void load(UpdatedComp comp) {
        comp.setText("##Chargement des ventes");
        cahier.load(comp);
        comp.setText("##Fin chargement des ventes");
    }

    @Override
    public String getName() {
        return "Ventes";
    }

    @Override
    public JComponent getComponent() {
        return this;
    }
}
